package data;

import javax.swing.table.AbstractTableModel;


public class UserTableModel extends AbstractTableModel {

	private Dao db;

	public UserTableModel() {
		db = new Dao();
		
	}

	public int getColumnCount() {
		return 5;
	}

	public int getRowCount() {
		return db.getUsers().size();
	}

	public String getColumnName(int columnIndex) {
		switch (columnIndex) {
		case 0:
			return "Email";
		case 1:
			return "Name";
		case 2:
			return "Password";
		case 3:
			return "Balance";
		case 4:
			return "Admin";
		}
		return null;
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		db.getUsers().get(rowIndex);

		switch (columnIndex) {

		case 0:
			return db.getUsers().get(rowIndex).getEmail();
		case 1:
			return db.getUsers().get(rowIndex).getName();
		case 2:
			return db.getUsers().get(rowIndex).getPassword();
		case 3:
			return db.getUsers().get(rowIndex).getBalance();
		case 4:
			return db.getUsers().get(rowIndex).getIsAdmin();
		}
		return getValueAt(rowIndex, columnIndex);
	}

}
